//
//  CallbacksProxy.h
//  MacDemo
//
//  Created by FH on 2020/11/18.
//  Copyright © 2020 FH. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef BOOL (^ProxyCanRespondBlock)(SEL _Nonnull);
typedef NSString * _Nonnull (^ProxySearchSignatureBlock)(SEL _Nonnull);
typedef void (^ProxyForwardInvocationBlock)(id _Nonnull);

NS_ASSUME_NONNULL_BEGIN

@interface ObjCInvokeParamInfo : NSObject

@property (nonatomic, strong, nonnull) NSString *name;
@property (nonatomic, strong, nonnull) NSString *declType;
@property (nonatomic, assign) BOOL isObjCRefType;

- (BOOL)canUseVoidPointer;

@end

@protocol ObjCInvokeProxyAdapterDelegate <NSObject>

@end

@interface ObjCInvokeProxy : NSObject

+ (id)getObjcRefValueWithInvocation:(id)invocation
                              index:(NSInteger)index
                     forReturnValue:(BOOL)forReturnValue;

- (id)createInstanceFromClass:(Class)cls;

- (instancetype)initWithCanRespondBlock:(ProxyCanRespondBlock _Nonnull)canRespondBlock
                   SearchSignatureBlock:(ProxySearchSignatureBlock _Nonnull)searchSignatureBlock
                 forwardInvocationBlock:(ProxyForwardInvocationBlock _Nonnull)forwardInvocationBlock;

- (void)invokeAPIWithInvocation:(id _Nonnull)invocation
                   blockArgName:(NSString * _Nullable)blockArgName
                  blockArgIndex:(NSInteger)blockArgIndex
                   blockArgInfo:(NSArray<ObjCInvokeParamInfo *> * _Nullable)blockArgInfo;

@end

id getObjValueByKeyPath(NSString * keyPath, NSObject *obj);

NS_ASSUME_NONNULL_END
